package com.ruoyi.system.config;

import com.ruoyi.system.domain.CacheTool;
import com.ruoyi.system.domain.BaseInfoParams;
import com.ruoyi.system.domain.BmCourse;
import com.ruoyi.system.domain.BmUnit;
import com.ruoyi.system.domain.BmWord;
import com.ruoyi.system.service.IBmCourseService;
import com.ruoyi.system.service.IBmUnitService;
import com.ruoyi.system.service.IBmWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class InitConfig implements ApplicationRunner {

    @Autowired
    private IBmCourseService iBmCourseService;
    @Autowired
    private IBmUnitService iBmUnitService;
    @Autowired
    private IBmWordService iBmWordService;

    //单元缓存
    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<BmCourse> bmCourses = iBmCourseService.selectBmCourseList(null);
        CacheTool.courseList = bmCourses;
        BaseInfoParams baseInfoParams = new BaseInfoParams();
        List<BmUnit> bmUnits = iBmUnitService.selectCourseUnitList(baseInfoParams);
        CacheTool.unitList = bmUnits;
        BmWord bmWord = new BmWord();
        List<BmWord> bmWords = iBmWordService.selectBmWordList(bmWord);
        CacheTool.wordList = bmWords;
    }
}
